define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'knscy.redpack_agent/index',
        add_url: 'knscy.redpack_agent/add',
        edit_url: 'knscy.redpack_agent/edit',
        delete_url: 'knscy.redpack_agent/delete',
        export_url: 'knscy.redpack_agent/export',
        modify_url: 'knscy.redpack_agent/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar:['refresh' ,'export'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'id', title: 'id',search: false},
                    {field: 'agent_sn', title: '编号SN', minWidth:150},
                    {field: 'redpack_no', title: '所属优惠券', minWidth:150},
                    {field: 'user_id', title: '用户ID', minWidth:150},
                    {field: 'redpack_type', search: 'select',  minWidth:180, selectList: {"1":"优惠券","2":"线下凭证"}, title: '类型'},

                    {field: 'discount', title: '折扣金额', minWidth:150,search: false},
                    {field: 'is_used', search: 'select', selectList: ["待用","已用"], title: '使用状态', minWidth:150},
                    {field: 'ticket_sn', title: '使用订单', minWidth:180, },
                    {field: 'use_time', title: '使用时间', minWidth:180,search:'time',},
                    {field: 'end_time', title: '结束时间', minWidth:180,search:'time',},
                    {field: 'sort', title: '排序', edit: 'text',search:false},
                    {field: 'status', search: 'select', selectList: ["禁用","启用"], title: '状态', templet: ea.table.switch},
                    {field: 'create_time', title: '创建时间', minWidth:180},
                    {fixed:"right",width: 180, title: '操作', templet: ea.table.tool},
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});